import { Context } from 'egg';

export default () => {
    return async (ctx: Context, next) => {
        const { app, socket } = ctx;
        const nsp = app.io.of('/');
        const id = socket.id;
        const query = socket.handshake.query;
        const { room, userId } = query;
        console.log(id, room, userId);
        const say = await ctx.service.userService.say();
        socket.emit('res', 'auth' + say);
        await next();
        console.log(nsp.adapter.clients);
        console.log('disconnect');
    }
}